﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace PuyoNeuron
{
    public class Camera
    {
        Vector2 mCenter;
        Vector2 mScreenSize;
        float mZoom;
        static Camera sInstance;

        public Vector2 Center
        {
            get { return mCenter; }
            set { mCenter = value; }
        }

        public Vector2 ScreenSize
        {
            get { return mScreenSize; }
            set { mScreenSize = value; }
        }

        public float Zoom
        {
            get { return mZoom; }
            set { mZoom = value; }
        }

        public static Camera Instance
        {
            get { return sInstance = sInstance ?? new Camera(); }
        }

        private Camera()
        {
            mCenter = Vector2.Zero;
            mZoom = 1f;
            mScreenSize = new Vector2(1024, 768);
        }

        public Vector2 ToScreen(Vector2 pWorld)
        {
            return (pWorld - mCenter) * mZoom + mScreenSize / 2;
        }

        public Vector2 ToWorld(Vector2 pScreen)
        {
            return (pScreen - mScreenSize / 2) / mZoom + mCenter;
        }
    }
}